<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PBHRK7');</script>
<!-- End Google Tag Manager -->
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="网站分析," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="GTM 基础入门（概念篇）面板介绍GTM后台上会有5个选项： 概览、代码、触发器、变量，文件夹 概览（Overview）：主要查看GTM上部署的代码变动记录，以及发布版本的管理 代码(Tag)主要是设置各种代码，通常通过GTM.js的脚本注入到网页中; 当满足触发器的触发条件时候，会向GA服务器发送数据请求，或者往页面执行JS脚本 触发器(Trigger)主要是设置促发条件，如特定点击，页面浏览，">
<meta name="keywords" content="网站分析">
<meta property="og:type" content="article">
<meta property="og:title" content="GTM 基础入门（概念篇）">
<meta property="og:url" content="http://wurh.github.io/2018/01/04/20180104/index.html">
<meta property="og:site_name" content="华Ing&#39;s blog">
<meta property="og:description" content="GTM 基础入门（概念篇）面板介绍GTM后台上会有5个选项： 概览、代码、触发器、变量，文件夹 概览（Overview）：主要查看GTM上部署的代码变动记录，以及发布版本的管理 代码(Tag)主要是设置各种代码，通常通过GTM.js的脚本注入到网页中; 当满足触发器的触发条件时候，会向GA服务器发送数据请求，或者往页面执行JS脚本 触发器(Trigger)主要是设置促发条件，如特定点击，页面浏览，">
<meta property="og:locale" content="en">
<meta property="og:image" content="https://wurh.github.io/images/blogs/20180104/p1.png">
<meta property="og:image" content="https://wurh.github.io/images/blogs/20180104/p2.png">
<meta property="og:image" content="https://wurh.github.io/images/blogs/20180104/p3.png">
<meta property="og:image" content="https://wurh.github.io/images/blogs/20180104/p4.png">
<meta property="og:image" content="https://wurh.github.io/images/blogs/20180104/p5.png">
<meta property="og:updated_time" content="2019-07-12T06:10:38.185Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="GTM 基础入门（概念篇）">
<meta name="twitter:description" content="GTM 基础入门（概念篇）面板介绍GTM后台上会有5个选项： 概览、代码、触发器、变量，文件夹 概览（Overview）：主要查看GTM上部署的代码变动记录，以及发布版本的管理 代码(Tag)主要是设置各种代码，通常通过GTM.js的脚本注入到网页中; 当满足触发器的触发条件时候，会向GA服务器发送数据请求，或者往页面执行JS脚本 触发器(Trigger)主要是设置促发条件，如特定点击，页面浏览，">
<meta name="twitter:image" content="https://wurh.github.io/images/blogs/20180104/p1.png">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: 'Author'
    }
  };
</script>




  <link rel="canonical" href="http://wurh.github.io/2018/01/04/20180104/"/>


  <title> GTM 基础入门（概念篇） | 华Ing's blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PBHRK7"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

  










  
  
    
  

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-69412379-1', 'auto');
  ga('send', 'pageview');

</script>

  <script>
  var _hmt = _hmt || [];
  (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b3ddfb8655d8b77429e04c7a4d5bcbc1";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
  })();
  </script>


  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">华Ing's blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">harder and harder</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                GTM 基础入门（概念篇）
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2018-01-04T19:40:00+08:00" content="2018-01-04">
              2018-01-04
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Google-Analysis/" itemprop="url" rel="index">
                    <span itemprop="name">Google Analysis</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2018/01/04/20180104/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2018/01/04/20180104/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="GTM-基础入门（概念篇）"><a href="#GTM-基础入门（概念篇）" class="headerlink" title="GTM 基础入门（概念篇）"></a>GTM 基础入门（概念篇）</h2><h3 id="面板介绍"><a href="#面板介绍" class="headerlink" title="面板介绍"></a>面板介绍</h3><p>GTM后台上会有5个选项： 概览、代码、触发器、变量，文件夹</p>
<h4 id="概览（Overview）："><a href="#概览（Overview）：" class="headerlink" title="概览（Overview）："></a>概览（Overview）：</h4><p>主要查看GTM上部署的代码变动记录，以及发布版本的管理</p>
<h4 id="代码-Tag"><a href="#代码-Tag" class="headerlink" title="代码(Tag)"></a>代码(Tag)</h4><p>主要是设置各种代码，通常通过GTM.js的脚本注入到网页中; 当满足触发器的触发条件时候，会向GA服务器发送数据请求，或者往页面执行JS脚本</p>
<h4 id="触发器-Trigger"><a href="#触发器-Trigger" class="headerlink" title="触发器(Trigger)"></a>触发器(Trigger)</h4><p>主要是设置促发条件，如特定点击，页面浏览，接收数据层事件等</p>
<h4 id="变量-Variable"><a href="#变量-Variable" class="headerlink" title="变量(Variable)"></a>变量(Variable)</h4><p>主要是预定义一些基础的字段，如Cookie，常量，抓页面属性，对照表，数据层变量等用于触发器和代码的使用</p>
<h4 id="文件夹-Folders"><a href="#文件夹-Folders" class="headerlink" title="文件夹(Folders)"></a>文件夹(Folders)</h4><p>主要是对上述 代码，触发器 以及变量的管理，方便后续项目整体维护跟踪</p>
<p>–</p>
<h3 id="内置变量"><a href="#内置变量" class="headerlink" title="内置变量"></a>内置变量</h3><p>内置变量是一种预先创建且不可自定义的特殊类别的变量。内置变量取代了以往创建新容器时生成的变量。<br>新容器一开始没有用户定义的变量，而是需要预先启用一些内置变量。用户可以根据自己的需要快速启用任何其他变量。</p>
<p><img src="https://wurh.github.io/images/blogs/20180104/p1.png" alt="内置变量"></p>
<p>–</p>
<h4 id="网页"><a href="#网页" class="headerlink" title="网页"></a>网页</h4><h5 id="Page-URL"><a href="#Page-URL" class="headerlink" title="Page URL"></a>Page URL</h5><p>当前网页的完整地址</p>
<h5 id="Page-Hostname"><a href="#Page-Hostname" class="headerlink" title="Page Hostname"></a>Page Hostname</h5><p>当前网站的主机名部分（域名）</p>
<h5 id="Page-Path"><a href="#Page-Path" class="headerlink" title="Page Path"></a>Page Path</h5><p>当前网站的路径部分</p>
<h5 id="Referrer"><a href="#Referrer" class="headerlink" title="Referrer"></a>Referrer</h5><p>当前网页的入口来源</p>
<p>–</p>
<h4 id="实用工具"><a href="#实用工具" class="headerlink" title="实用工具"></a>实用工具</h4><h5 id="Event"><a href="#Event" class="headerlink" title="Event"></a>Event</h5><p>访问 dataLayer 中的“event”键，是当前 dataLayer 事件的名称（如 gtm.js、gtm.dom、gtm.load 或自定义事件名称）。Eg：预定义dataLayer的event，可以再页面促发的时候直接dataLayer.push 事件的形式，用触发器的的自定义事件接受</p>
<h5 id="Environment-Name"><a href="#Environment-Name" class="headerlink" title="Environment Name"></a>Environment Name</h5><p>如果通过环境“共享预览”链接或通过环境代码段发出容器请求，则返回用户提供的当前环境名称。对于内置环境，将返回“已发布”、“最新”或“正在修改”。在包括非环境容器请求的其他所有情况下，会返回空字符串。</p>
<h5 id="Container-ID"><a href="#Container-ID" class="headerlink" title="Container ID"></a>Container ID</h5><p>容器的公共 ID</p>
<h5 id="Container-Version"><a href="#Container-Version" class="headerlink" title="Container Version"></a>Container Version</h5><p>容器的版本号</p>
<h5 id="Random-Number"><a href="#Random-Number" class="headerlink" title="Random Number"></a>Random Number</h5><p>生成一个介于 0 到 2147483647 之间的随机整数</p>
<p>–</p>
<h4 id="错误"><a href="#错误" class="headerlink" title="错误"></a>错误</h4><h5 id="Error-Message（错误消息）"><a href="#Error-Message（错误消息）" class="headerlink" title="Error Message（错误消息）"></a>Error Message（错误消息）</h5><p>访问 dataLayer 中的“gtm.errorMessage”键，由 JavaScript 错误触发器设置。这是一个包含错误消息的字符串。</p>
<h6 id="Error-URL（错误网址）"><a href="#Error-URL（错误网址）" class="headerlink" title="Error URL（错误网址）"></a>Error URL（错误网址）</h6><p>访问 dataLayer 中的“gtm.errorUrl”键，由 JavaScript 错误触发器设置。这是一个包含出现错误的网址的字符串。</p>
<h5 id="Error-Line（错误行）"><a href="#Error-Line（错误行）" class="headerlink" title="Error Line（错误行）"></a>Error Line（错误行）</h5><p>访问 dataLayer 中的“gtm.errorLine”键，由 JavaScript 错误触发器设置。这是一个出现错误的网址中的行号。</p>
<h5 id="Debug-Mode（调试模式）"><a href="#Debug-Mode（调试模式）" class="headerlink" title="Debug Mode（调试模式）"></a>Debug Mode（调试模式）</h5><p>如果容器当前在预览模式下运行，将返回 true。</p>
<p>–</p>
<h4 id="点击-–-可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值"><a href="#点击-–-可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值" class="headerlink" title="点击  – 可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值"></a>点击  – 可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值</h4><h5 id="Click-Element（点击元素）"><a href="#Click-Element（点击元素）" class="headerlink" title="Click Element（点击元素）"></a>Click Element（点击元素）</h5><p>访问 dataLayer 中的“gtm.element”键，由“点击”触发器设置。这是对发生点击的 DOM 元素的引用。</p>
<h5 id="Click-Classes（点击类）"><a href="#Click-Classes（点击类）" class="headerlink" title="Click Classes（点击类）"></a>Click Classes（点击类）</h5><p>访问 dataLayer 中的“gtm.elementClasses”键，由“点击”触发器设置。这是被点击的 DOM 元素的类属性的字符串值。</p>
<h5 id="Click-ID（点击-ID）"><a href="#Click-ID（点击-ID）" class="headerlink" title="Click ID（点击 ID）"></a>Click ID（点击 ID）</h5><p>访问 dataLayer 中的“gtm.elementId”键，由“点击”触发器设置。这是被点击的 DOM 元素的 ID 属性的字符串值。</p>
<h5 id="Click-Target（点击目标）"><a href="#Click-Target（点击目标）" class="headerlink" title="Click Target（点击目标）"></a>Click Target（点击目标）</h5><p>访问 dataLayer 中的“gtm.elementTarget”键，由“点击”触发器设置。</p>
<h5 id="Click-URL（点击网址）"><a href="#Click-URL（点击网址）" class="headerlink" title="Click URL（点击网址）"></a>Click URL（点击网址）</h5><p>访问 dataLayer 中的“gtm.elementUrl”键，由“点击”触发器设置。</p>
<h5 id="Click-Text（点击文字）"><a href="#Click-Text（点击文字）" class="headerlink" title="Click Text（点击文字）"></a>Click Text（点击文字）</h5><p>访问 dataLayer 中的“gtm.elementText”键，由“点击”触发器设置。</p>
<p>–</p>
<h4 id="表单-–-可理解datalayer中可访问表单元素的方式与获取该元素的值"><a href="#表单-–-可理解datalayer中可访问表单元素的方式与获取该元素的值" class="headerlink" title="表单 – 可理解datalayer中可访问表单元素的方式与获取该元素的值"></a>表单 – 可理解datalayer中可访问表单元素的方式与获取该元素的值</h4><h5 id="Form-Element（表单元素）："><a href="#Form-Element（表单元素）：" class="headerlink" title="Form Element（表单元素）："></a>Form Element（表单元素）：</h5><p>访问 dataLayer 中的“gtm.element”键，由“表单”触发器设置。这是对表单的 DOM 元素的引用。</p>
<h5 id="Form-Classes（表单类）："><a href="#Form-Classes（表单类）：" class="headerlink" title="Form Classes（表单类）："></a>Form Classes（表单类）：</h5><p>访问 dataLayer 中的“gtm.elementClasses”键，由“表单”触发器设置。这是表单的类属性的字符串值。</p>
<h5 id="Form-ID（表单-ID）："><a href="#Form-ID（表单-ID）：" class="headerlink" title="Form ID（表单 ID）："></a>Form ID（表单 ID）：</h5><p>访问 dataLayer 中“gtm.elementId”键，由“表单”触发器设置。这是表单的 ID 属性的字符串值。</p>
<h5 id="Form-Target（表单目标）："><a href="#Form-Target（表单目标）：" class="headerlink" title="Form Target（表单目标）："></a>Form Target（表单目标）：</h5><p>访问 dataLayer 中的“gtm.elementTarget”键，由“表单”触发器设置。</p>
<h5 id="Form-URL（表单网址）："><a href="#Form-URL（表单网址）：" class="headerlink" title="Form URL（表单网址）："></a>Form URL（表单网址）：</h5><p>访问 dataLayer 中的“gtm.elementUrl”键，由“表单”触发器设置。</p>
<h5 id="Form-Text（表单文字）："><a href="#Form-Text（表单文字）：" class="headerlink" title="Form Text（表单文字）："></a>Form Text（表单文字）：</h5><p>访问 dataLayer 中的“gtm.elementText”键，由“表单”触发器设置。</p>
<p>–</p>
<h4 id="历史记录（网站路由）"><a href="#历史记录（网站路由）" class="headerlink" title="历史记录（网站路由）"></a>历史记录（网站路由）</h4><h5 id="New-History-Fragment（新历史记录片段）："><a href="#New-History-Fragment（新历史记录片段）：" class="headerlink" title="New History Fragment（新历史记录片段）："></a>New History Fragment（新历史记录片段）：</h5><p>访问 dataLayer 中的“gtm.newUrlFragment”键，由“历史记录更改”触发器设置。这是发生历史记录事件后相应网页网址的片段（即哈希）部分的字符串值。</p>
<h5 id="Old-History-Fragment（旧历史记录片段）："><a href="#Old-History-Fragment（旧历史记录片段）：" class="headerlink" title="Old History Fragment（旧历史记录片段）："></a>Old History Fragment（旧历史记录片段）：</h5><p>访问 dataLayer 中的“gtm.oldUrlFragment”键，由“历史记录更改”触发器设置。这是发生历史记录事件前相应网页网址的片段（即哈希）部分的字符串值。</p>
<h5 id="New-History-State（新历史记录状态）："><a href="#New-History-State（新历史记录状态）：" class="headerlink" title="New History State（新历史记录状态）："></a>New History State（新历史记录状态）：</h5><p>访问 dataLayer 中的“gtm.newHistoryState”键，由“历史记录更改”触发器设置。这是网页推送到历史记录以触发历史记录事件的状态对象。</p>
<h5 id="Old-History-State（旧历史记录状态）："><a href="#Old-History-State（旧历史记录状态）：" class="headerlink" title="Old History State（旧历史记录状态）："></a>Old History State（旧历史记录状态）：</h5><p>访问 dataLayer 中的“gtm.oldHistoryState”键，由“历史记录更改”触发器设置。这是发生历史记录事件前处于活动状态的状态对象。</p>
<h5 id="History-Source（历史记录来源）："><a href="#History-Source（历史记录来源）：" class="headerlink" title="History Source（历史记录来源）："></a>History Source（历史记录来源）：</h5><p>访问 dataLayer 中的“gtm.historyChangeSource”键，由“历史记录更改”触发器设置<br>上面是GTM默认已有的基础变量，但实际使用的过程中还经常会用到其他一些自定义变量</p>
<p>–</p>
<h3 id="自定义变量"><a href="#自定义变量" class="headerlink" title="自定义变量"></a>自定义变量</h3><h4 id="第一方Cookie"><a href="#第一方Cookie" class="headerlink" title="第一方Cookie"></a>第一方Cookie</h4><p>第一方Cookie变量返回的是浏览器cookie中该变量的值，例如cookie中有个字段是userid,值为1514894261083，在Tag中设置该name，就可以在GTM中将该值读入</p>
<p><img src="https://wurh.github.io/images/blogs/20180104/p2.png" alt="第一方cookie"></p>
<p><img src="https://wurh.github.io/images/blogs/20180104/p3.png" alt="第一方cookie"></p>
<h4 id="常量"><a href="#常量" class="headerlink" title="常量"></a>常量</h4><p>代码中经常实用的变量，我们可以定义为一个常量， 如trackid – 指定 GA ID</p>
<h4 id="自定义JS脚本"><a href="#自定义JS脚本" class="headerlink" title="自定义JS脚本"></a>自定义JS脚本</h4><p>可以通过js脚本进行网页注入，获取页面数据； 如</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 判断用户是否登录脚本</span></span><br><span class="line">  <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (&#123;&#123;MID <span class="keyword">in</span> Cookie&#125;&#125;) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">"Registered"</span>;</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">return</span> <span class="string">"Unregistered"</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="数据层变量"><a href="#数据层变量" class="headerlink" title="数据层变量"></a>数据层变量</h4><p>主要用于datalayer.push 结合使用<br>如我定义一个Sign in Type的变量</p>
<p><img src="https://wurh.github.io/images/blogs/20180104/p4.png" alt="数据层变量"></p>
<p>我们可以从datalayer中找回对应事件的变量值</p>
<p><img src="https://wurh.github.io/images/blogs/20180104/p5.png" alt="数据层变量"></p>
<h6 id="文章借鉴"><a href="#文章借鉴" class="headerlink" title="文章借鉴"></a>文章借鉴</h6>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="https://wurh.github.io/images/others/weixinshou.png" alt="华Ing WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="https://wurh.github.io/images/others/alifu.png" alt="华Ing Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/网站分析/" rel="tag">#网站分析</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/11/14/20171114/" rel="next" title="Vue 多页面脚手架">
                <i class="fa fa-chevron-left"></i> Vue 多页面脚手架
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/05/15/20180515/" rel="prev" title="Pagium2.0使用文档">
                Pagium2.0使用文档 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        
<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2018/01/04/20180104/"
           data-title="GTM 基础入门（概念篇）" data-url="http://wurh.github.io/2018/01/04/20180104/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="https://wurh.github.io/images/avatar/logo.jpg?123456"
               alt="华Ing" />
          <p class="site-author-name" itemprop="name">华Ing</p>
          <p class="site-description motion-element" itemprop="description">harder and harder</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">56</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/wurh" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/1674582564/profile?topnav=1&wvr=6" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/wu-rong-hua-56" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://fsiaonma.github.io/" title="sam博客" target="_blank">sam博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://shenjoel.github.io/" title="joel博客" target="_blank">joel博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://firewood1122.github.io" title="firewood博客" target="_blank">firewood博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://reqianduan.com" title="热前端" target="_blank">热前端</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://opentutorial.info/" title="黄超博客" target="_blank">黄超博客</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#GTM-基础入门（概念篇）"><span class="nav-number">1.</span> <span class="nav-text">GTM 基础入门（概念篇）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#面板介绍"><span class="nav-number">1.1.</span> <span class="nav-text">面板介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#概览（Overview）："><span class="nav-number">1.1.1.</span> <span class="nav-text">概览（Overview）：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#代码-Tag"><span class="nav-number">1.1.2.</span> <span class="nav-text">代码(Tag)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#触发器-Trigger"><span class="nav-number">1.1.3.</span> <span class="nav-text">触发器(Trigger)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#变量-Variable"><span class="nav-number">1.1.4.</span> <span class="nav-text">变量(Variable)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#文件夹-Folders"><span class="nav-number">1.1.5.</span> <span class="nav-text">文件夹(Folders)</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#内置变量"><span class="nav-number">1.2.</span> <span class="nav-text">内置变量</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#网页"><span class="nav-number">1.2.1.</span> <span class="nav-text">网页</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Page-URL"><span class="nav-number">1.2.1.1.</span> <span class="nav-text">Page URL</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Page-Hostname"><span class="nav-number">1.2.1.2.</span> <span class="nav-text">Page Hostname</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Page-Path"><span class="nav-number">1.2.1.3.</span> <span class="nav-text">Page Path</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Referrer"><span class="nav-number">1.2.1.4.</span> <span class="nav-text">Referrer</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实用工具"><span class="nav-number">1.2.2.</span> <span class="nav-text">实用工具</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Event"><span class="nav-number">1.2.2.1.</span> <span class="nav-text">Event</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Environment-Name"><span class="nav-number">1.2.2.2.</span> <span class="nav-text">Environment Name</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Container-ID"><span class="nav-number">1.2.2.3.</span> <span class="nav-text">Container ID</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Container-Version"><span class="nav-number">1.2.2.4.</span> <span class="nav-text">Container Version</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Random-Number"><span class="nav-number">1.2.2.5.</span> <span class="nav-text">Random Number</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#错误"><span class="nav-number">1.2.3.</span> <span class="nav-text">错误</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Error-Message（错误消息）"><span class="nav-number">1.2.3.1.</span> <span class="nav-text">Error Message（错误消息）</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#Error-URL（错误网址）"><span class="nav-number">1.2.3.1.1.</span> <span class="nav-text">Error URL（错误网址）</span></a></li></ol></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Error-Line（错误行）"><span class="nav-number">1.2.3.2.</span> <span class="nav-text">Error Line（错误行）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Debug-Mode（调试模式）"><span class="nav-number">1.2.3.3.</span> <span class="nav-text">Debug Mode（调试模式）</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#点击-–-可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值"><span class="nav-number">1.2.4.</span> <span class="nav-text">点击  – 可理解datalayer中可访问主文档（HTML）dom元素的方式与获取该元素的值</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-Element（点击元素）"><span class="nav-number">1.2.4.1.</span> <span class="nav-text">Click Element（点击元素）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-Classes（点击类）"><span class="nav-number">1.2.4.2.</span> <span class="nav-text">Click Classes（点击类）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-ID（点击-ID）"><span class="nav-number">1.2.4.3.</span> <span class="nav-text">Click ID（点击 ID）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-Target（点击目标）"><span class="nav-number">1.2.4.4.</span> <span class="nav-text">Click Target（点击目标）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-URL（点击网址）"><span class="nav-number">1.2.4.5.</span> <span class="nav-text">Click URL（点击网址）</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Click-Text（点击文字）"><span class="nav-number">1.2.4.6.</span> <span class="nav-text">Click Text（点击文字）</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#表单-–-可理解datalayer中可访问表单元素的方式与获取该元素的值"><span class="nav-number">1.2.5.</span> <span class="nav-text">表单 – 可理解datalayer中可访问表单元素的方式与获取该元素的值</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-Element（表单元素）："><span class="nav-number">1.2.5.1.</span> <span class="nav-text">Form Element（表单元素）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-Classes（表单类）："><span class="nav-number">1.2.5.2.</span> <span class="nav-text">Form Classes（表单类）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-ID（表单-ID）："><span class="nav-number">1.2.5.3.</span> <span class="nav-text">Form ID（表单 ID）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-Target（表单目标）："><span class="nav-number">1.2.5.4.</span> <span class="nav-text">Form Target（表单目标）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-URL（表单网址）："><span class="nav-number">1.2.5.5.</span> <span class="nav-text">Form URL（表单网址）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Form-Text（表单文字）："><span class="nav-number">1.2.5.6.</span> <span class="nav-text">Form Text（表单文字）：</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#历史记录（网站路由）"><span class="nav-number">1.2.6.</span> <span class="nav-text">历史记录（网站路由）</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#New-History-Fragment（新历史记录片段）："><span class="nav-number">1.2.6.1.</span> <span class="nav-text">New History Fragment（新历史记录片段）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Old-History-Fragment（旧历史记录片段）："><span class="nav-number">1.2.6.2.</span> <span class="nav-text">Old History Fragment（旧历史记录片段）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#New-History-State（新历史记录状态）："><span class="nav-number">1.2.6.3.</span> <span class="nav-text">New History State（新历史记录状态）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Old-History-State（旧历史记录状态）："><span class="nav-number">1.2.6.4.</span> <span class="nav-text">Old History State（旧历史记录状态）：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#History-Source（历史记录来源）："><span class="nav-number">1.2.6.5.</span> <span class="nav-text">History Source（历史记录来源）：</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自定义变量"><span class="nav-number">1.3.</span> <span class="nav-text">自定义变量</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#第一方Cookie"><span class="nav-number">1.3.1.</span> <span class="nav-text">第一方Cookie</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#常量"><span class="nav-number">1.3.2.</span> <span class="nav-text">常量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#自定义JS脚本"><span class="nav-number">1.3.3.</span> <span class="nav-text">自定义JS脚本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#数据层变量"><span class="nav-number">1.3.4.</span> <span class="nav-text">数据层变量</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#文章借鉴"><span class="nav-number">1.3.4.0.1.</span> <span class="nav-text">文章借鉴</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2013 - 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">华Ing</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.2"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"wurh"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  

  


</body>
</html>
